$:.unshift File.join(File.dirname(__FILE__))
require 'test_helper'

class TestUpperScore < Test::Unit::TestCase

  def test_odds_1
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 6}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 1, u_score.odds )
  end

  def test_odds_1
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 6}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 1, u_score.odds )
    assert !u_score.optional_roll?
  end

  def test_odds_1_optional_roll
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 5}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 1, u_score.odds )
    assert u_score.optional_roll?
  end

  def test_odds_two_out_of_three_thrown
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 2}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 0.52, u_score.odds )
  end

  def test_odds_one_out_of_three_thrown
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 1}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 0.19, u_score.odds )
  end

  def test_odds_zero_out_of_three_thrown
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 0}, 6))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 0.00, u_score.odds )
  end
  
  def test_points_three_ones
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 3}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 3, u_score.points )
  end

  def test_points_two_ones
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 2}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 2, u_score.points )
  end

  def test_points_one_ones
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 1}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 1, u_score.points )
  end

  def test_points_zero_ones
    t = Yahtzee::Turn.new(Yahtzee::Dice.new({1 => 0}))
    u_score = Yahtzee::UpperScore.new(t,1)
    assert_equal( 0, u_score.points )
  end

end